IconHelper: Avoid warnings for non-existing stock ids
authorAlexander Larsson <alexl@redhat.com>
Thu, 13 Dec 2012 09:08:37 +0000 (10:08 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 13 Dec 2012 09:11:00 +0000 (10:11 +0100)
There are some registred stock ids like gtk-discards that have no icons,
and you could also pass a non-registred stock id. Both of these means
gtk_style_context_lookup_icon_set returns NULL, which causes
a critical in gtk_icon_set_render_icon_pixbuf.

We avoid this by just making these render as EMPTY.

gtk/gtkiconhelper.c

index 6f23914a8c5e83b41b3e700d5d14ad851a034619..74eae6901d61efeb132ba18b570022a4e8acadd8 100644 (file)
@@ -325,7 +325,10 @@ _gtk_icon_helper_ensure_pixbuf (GtkIconHelper *self,
 
     case GTK_IMAGE_STOCK:
       icon_set = gtk_style_context_lookup_icon_set (context, self->priv->stock_id);
-      ensure_pixbuf_for_icon_set (self, context, icon_set);
+      if (icon_set != NULL)
+       ensure_pixbuf_for_icon_set (self, context, icon_set);
+      else
+       pixbuf = NULL;
       break;
 
     case GTK_IMAGE_ICON_SET: